package com.yangff.listener;

import com.yangff.entity.admin.entity.Productmanagement;
import com.yangff.service.IProductmanagementService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class ManagementListener {
    private final IProductmanagementService productmanagementService;

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(name = "management.queue"),
                    exchange = @Exchange(name = "fts.direct",type = ExchangeTypes.DIRECT),
                    key = "saveproduct"
            )
    )
    public void saveProductManagement(Productmanagement productmanagement) {
        productmanagementService.saveProductlog(productmanagement);
    }
}
